/**
 * Title:        代理数据同步
 * Company:      泛微软件
 */


package checkDetail;

import general.BaseBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import weaver.general.GCONST;
import weaver.general.OrderProperties;



public class FreeFlowCheck extends BaseBean implements CheckBase  {

    @Override
    public JSONObject checkData(HashMap dataMap) {
        setRecordSet();
        (new BaseBean()).writeLog("FreeFlowCheck  start");

        List resultList = new ArrayList();
        String result = resultOk;

        String freeFlow =null2String(getPropValue("FreeFlow","FREEFLOW"));
        if(!freeFlow.equals("Y")){
            result = resultNeedFix;
            Map resultMap = new HashMap<String,String>();
            resultMap.put("showMessage","没有开启自由流转设置");
            resultMap.put("buttonname","修复");
            resultList.add(resultMap);
        }
        (new BaseBean()).writeLog("FreeFlowCheck  end");
        return formatReturnJsonCheck(result, resultList,this);
    }

    @Override
    public JSONObject fixData(HashMap dataMap) {
        List resultList = new ArrayList();
        String result = resultOk;
        OrderProperties webSignprop = new OrderProperties();
        webSignprop.load(GCONST.getPropertyPath()+ "FreeFlow.properties");
        webSignprop.put("FREEFLOW", "Y");
        webSignprop.store(webSignprop, GCONST.getPropertyPath() + "FreeFlow.properties");
        result = resultOk;
        if(dataMap!= null && dataMap.get("divid")!= null){
            Map resultMap = new HashMap<String,String>();
            resultMap.put("result",resultOk);
            resultMap.put("fixMessage","修复成功");
            resultMap.put("divid",dataMap.get("divid"));
            resultList.add(resultMap);
            return formatReturnJsonFix(result, resultList,this);
        }
        return checkData(new HashMap());
    }

    @Override
    public String getClassName() {
        return "自由流转设置检测";
    }

    @Override
    public String getClassDesc() {
        return "检测自由流转设置是否开启";
    }

}



